import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '@/views/HomeView.vue'
import LoginView from '@/views/LoginView.vue'
import DashboardView from '@/views/DashboardView.vue'

console.log(window.app.$progress)
const router = createRouter({
  history: createWebHistory(process.env.BASE_URL || '/'),
  routes: [
    {
      path: '/',
      redirect: '/home'
    },
    {
      path: '/home',
      name: 'home',
      component: HomeView,
      children: [
        {
          path: '',
          redirect: 'dashboard'
        },
        {
          path: '/dashboard',
          name: 'dashboard',
          component: DashboardView
        },
        {
          path: '/project',
          children: [
            {
              path: '',
              redirect: 'projectgroup'
            },
            {
              path: 'group',
              name: 'projectgroup',
              component: () => import('@/views/ProjectGroupView.vue')
            },
            {
              path: 'list',
              name: 'projects',
              component: () => import('@/views/ProjectView.vue')
            },
            {
              path: 'config',
              name: 'projectconfig',
              component: () => import('@/views/ProjectView.vue')
            }
          ]
        },
        {
          path: ':pathMatch(.*)*',
          redirect: { name: 'dashboard' }
        }
      ],
      redirect: { name: 'dashboard' }
    },
    {
      path: '/login',
      name: 'login',
      component: LoginView,
      default: true
    }
  ]
})

export default router
